//
//  CustomBottomView.m
//  JJHW_coreData
//
//  Created by lizhenqiang on 16/4/10.
//  Copyright © 2016年 HFKJ_LZQ. All rights reserved.
//

#import "CustomBottomView.h"

@implementation CustomBottomView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _myWidth = frame.size.width;
        _myHeight = frame.size.height;
        _dataArray = [NSMutableArray new];
        _carouselView =
        ({
            iCarousel *icarousel = [[iCarousel alloc] initWithFrame:CGRectMake(0, 0, DeviceWidth, 49)];
            icarousel.dataSource = self;
            icarousel.delegate = self;
//            icarousel.decelerationRate = 1.0;
//            icarousel.scrollSpeed = 1.0;
            icarousel.type = iCarouselTypeLinear;
//            icarousel.pagingEnabled = YES;
//            icarousel.clipsToBounds = YES;
//            icarousel.bounceDistance = 0.2;
            [self addSubview:icarousel];
//            [icarousel mas_makeConstraints:^(MASConstraintMaker *make)
//             {
//                 make.edges.equalTo(self).insets(UIEdgeInsetsMake(0, 0, 0, 0));
//             }];
            icarousel;
        });
    }
    return self;
}

-(void)setViewData:(NSMutableArray *)array
{
    
}

#pragma mark - iCarousel methods

- (NSInteger)numberOfItemsInCarousel:(__unused iCarousel *)carousel
{
    return _dataArray.count;
    
}

- (UIView *)carousel:(__unused iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{

//    CGFloat screenW = DeviceWidth;
//    UIImageView *imgView = nil;
//    if (view == nil){
//    view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenW/4.0, screenW*280.0/1080.0)];
//    imgView = [[UIImageView alloc] initWithFrame:CGRectMake((view.frame.size.width-screenW*260.0/1080.0)/2.0, screenW*10.0/1080.0, screenW*260.0/1080.0, screenW*260.0/1080.0)];
//    imgView.tag = 2001;
//    [view addSubview:imgView];
//    }else{
//        imgView = (UIImageView *)[view viewWithTag:2001];
//    }
//        return view;
    return nil;
    
}
- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
    //self.VC push
}

- (CGFloat)carousel:(__unused iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
    switch (option)
    {
        case iCarouselOptionWrap:
        {
            //normally you would hard-code this to YES or NO
            return YES;
        }
        case iCarouselOptionSpacing:
        {
            //add a bit of spacing between the item views
            return value;
        }
        case iCarouselOptionFadeMax:
        {
            return 0.0f;
        }
        case iCarouselOptionShowBackfaces:
        {
            return YES;
        }
        case iCarouselOptionRadius:
        case iCarouselOptionAngle:
        case iCarouselOptionArc:
        case iCarouselOptionTilt:
        case iCarouselOptionCount:
        case iCarouselOptionFadeMin:
        case iCarouselOptionFadeMinAlpha:
        case iCarouselOptionFadeRange:
        case iCarouselOptionOffsetMultiplier:
        case iCarouselOptionVisibleItems:
        {
//            return 5;
             return value;
        }
    }
    //return value;
}

@end
